package org.tigris.subversion.svnant.commands;

import java.io.File;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNRevision;
import org.tigris.subversion.svnclientadapter.SVNUrl;

public class Diff extends SvnCommand
{
  private static final String MSG_CANT_GET_DIFFERENCES = "Can't get the differences";
  private static final String MSG_INVALID_PATH_URL_MIXUP = "paths cannot be with urls when diffing";
  private SVNUrl oldUrl = null;
  private SVNUrl newUrl = null;
  private File oldPath = null;
  private File newPath = null;
  private SVNRevision oldTargetRevision = null;
  private SVNRevision newTargetRevision = null;
  private File outFile = new File("patch");
  private boolean recurse = true;

  public void execute()
  {
    try
    {
      if (this.oldUrl != null)
        getClient().diff(this.oldUrl, this.oldTargetRevision, this.newUrl, this.newTargetRevision, this.outFile, this.recurse);
      else
        getClient().diff(this.oldPath, this.oldTargetRevision, this.newPath, this.newTargetRevision, this.outFile, this.recurse);
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Can't get the differences", new Object[0]);
    }
  }

  protected void validateAttributes()
  {
    if (this.oldUrl != null)
    {
      if ((this.oldPath != null) || (this.newPath != null))
        throw ex("paths cannot be with urls when diffing", new Object[0]);
    }
    else if ((this.oldUrl != null) || (this.newUrl != null))
      throw ex("paths cannot be with urls when diffing", new Object[0]);
  }

  public void setNewPath(File paramFile)
  {
    this.newPath = paramFile;
  }

  public void setNewTargetRevision(String paramString)
  {
    this.newTargetRevision = getRevisionFrom(paramString);
  }

  protected SVNRevision getNewTargetRevision()
  {
    return this.newTargetRevision;
  }

  public void setNewUrl(SVNUrl paramSVNUrl)
  {
    this.newUrl = paramSVNUrl;
  }

  protected SVNUrl getNewUrl()
  {
    return this.newUrl;
  }

  public void setOldPath(File paramFile)
  {
    this.oldPath = paramFile;
  }

  public void setOldTargetRevision(String paramString)
  {
    this.oldTargetRevision = getRevisionFrom(paramString);
  }

  protected SVNRevision getOldTargetRevision()
  {
    return this.oldTargetRevision;
  }

  public void setOldUrl(SVNUrl paramSVNUrl)
  {
    this.oldUrl = paramSVNUrl;
  }

  protected SVNUrl getOldUrl()
  {
    return this.oldUrl;
  }

  public void setOutFile(File paramFile)
  {
    this.outFile = paramFile;
  }

  protected File getOutFile()
  {
    return this.outFile;
  }

  public void setRecurse(boolean paramBoolean)
  {
    this.recurse = paramBoolean;
  }

  protected void logAction(boolean paramBoolean)
  {
    StringBuilder localStringBuilder = new StringBuilder("# diff ");
    localStringBuilder.append(paramBoolean ? this.oldUrl : this.oldPath);
    localStringBuilder.append(" ");
    localStringBuilder.append(this.oldTargetRevision);
    log(localStringBuilder.toString());
    localStringBuilder.setLength(0);
    localStringBuilder.append("#      ");
    localStringBuilder.append(paramBoolean ? this.newUrl : this.newPath);
    localStringBuilder.append(" ");
    localStringBuilder.append(this.newTargetRevision);
    log(localStringBuilder.toString());
    if (this.outFile != null)
      log("# to outfile: " + this.outFile.getAbsolutePath());
  }
}

/* Location:           C:\Users\Administrator\Desktop\svnant.jar
 * Qualified Name:     org.tigris.subversion.svnant.commands.Diff
 * JD-Core Version:    0.6.0
 */